package com.youth.mapper;

import com.youth.entity.po.OrderShipping;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface IOrderShippingMapper {

    @Insert("insert into tb_order_shipping (order_id,receiver_name,receiver_phone,receiver_mobile,receiver_state,receiver_city,receiver_district,receiver_address,receiver_zip,create_time,update_time)" +
            "value (#{orderId},#{receiverName},#{receiverPhone},#{receiverMobile},#{receiverState},#{receiverCity},#{receiverDistrict},#{receiverAddress},#{receiverZip},#{createTime},#{updateTime})")
    int insert(OrderShipping record);

    @Update("<script>" +
            "update  tb_order_shipping " +
            "set update_time=#{updateTime}" +
            "<if test='receiverName != null'> " + " ,receiver_name =#{receiverName}" +
            "</if>" +
            "<if test='receiverPhone != null'> " + ", receiver_phone =#{receiverPhone}" +
            "</if>" +
            "<if test='receiverMobile != null'> " + ", receiver_mobile =#{receiverMobile}" +
            "</if>" +
            "<if test='receiverState != null'> " + ", receiver_state =#{receiverState}" +
            "</if>" +
            "<if test='receiverCity != null'> " + ", receiver_city =#{receiverCity}" +
            "</if>" +
            "<if test='receiverDistrict != null'> " + ", receiver_district =#{receiverDistrict}" +
            "</if>" +
            "<if test='receiverAddress != null'> " + ", receiver_address =#{receiverAddress}" +
            "</if>" +
            "<if test='receiverZip != null'> " + ", receiver_zip =#{receiverZip}" +
            "</if>" +
            "  where order_id=#{orderId}" +
            "</script>")
    int updateOrderShipping(OrderShipping record);
}